﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SQL_Provider;
using System.Data;
using System.Data.SqlClient;
using BusinessEntities;

namespace DataAccess
{
    public class PhieuTheoDoi_Adapter
    {
        Provider db;
        public PhieuTheoDoi_Adapter()
        {
            db = new Provider();
        }

        public DataTable PhongBenh_TimTheoMaYTa(string MaYTa)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            return db.Execute_Table("PhongBenh_TimTheoMaYTa", para, CommandType.StoredProcedure);
        }

        public int PhieuTheoDoi_Them(PhieuTheoDoi_Info info)
        {
            SqlParameter[] para = new SqlParameter[6];
            para[0] = new SqlParameter("@MaPhieu", info.MaPhieu);
            para[1] = new SqlParameter("@MaBA", info.MaBA);
            para[2] = new SqlParameter("@ThoiGianGhi", info.NgayGhiPhieu);
            para[3] = new SqlParameter("@DienBien", info.DienBien);
            para[4] = new SqlParameter("@MaYTa", info.MaYTa);
            para[5] = new SqlParameter("@TenYTa", info.TenYTa);
            return db.Execute_Modify("PhieuTheoDoi_Them", para, CommandType.StoredProcedure);
        }

        public int PhieuTheoDoi_CapNhat(PhieuTheoDoi_Info info)
        {
            SqlParameter[] para = new SqlParameter[6];
            para[0] = new SqlParameter("@MaPhieu", info.MaPhieu);
            para[1] = new SqlParameter("@MaBA", info.MaBA);
            para[2] = new SqlParameter("@ThoiGianGhi", info.NgayGhiPhieu);
            para[3] = new SqlParameter("@DienBien", info.DienBien);
            para[4] = new SqlParameter("@MaYTa", info.MaYTa);
            para[5] = new SqlParameter("@TenYTa", info.TenYTa);
            return db.Execute_Modify("PhieuTheoDoi_CapNhat", para, CommandType.StoredProcedure);
        }

        public int PhieuTheoDoi_Xoa(int MaPhieu)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaPhieu", MaPhieu);
            return db.Execute_Modify("PhieuTheoDoi_Xoa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_All_TrongNgay(string MaYTa)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            return db.Execute_Table("PhieuTheoDoi_All_TrongNgay", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_All_MaYTa(string MaYTa)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            return db.Execute_Table("PhieuTheoDoi_All_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoMaPhieu_MaYTa(string MaYTa, int MaPhieu)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            para[1] = new SqlParameter("@MaPhieu", MaPhieu);
            return db.Execute_Table("PhieuTheoDoi_TimTheoMaPhieu_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_MaBA(int MaBA)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBA", MaBA);
            return db.Execute_Table("PhieuTheoDoi_MaBA", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoMaBA_MaYTa(string MaYTa, int MaBA)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            para[1] = new SqlParameter("@MaBA", MaBA);
            return db.Execute_Table("PhieuTheoDoi_TimTheoMaBA_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoNgayGhi_MaYTa(string MaYTa, DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            para[1] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuTheoDoi_TimTheoNgayGhi_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoThangGhi_MaYTa(string MaYTa, DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            para[1] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuTheoDoi_TimTheoThangGhi_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoNamGhi_MaYTa(string MaYTa, DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            para[1] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuTheoDoi_TimTheoNamGhi_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_BNXuatVien_MaYTa(string MaYTa)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            return db.Execute_Table("PhieuTheoDoi_BNXuatVien_MaYTa", para, CommandType.StoredProcedure);
        }

        // Tìm Kiếm Quản lý
        public DataTable PhieuTheoDoi_TimTheoMaYTa(string MaYTa)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaYTa", MaYTa);
            return db.Execute_Table("PhieuTheoDoi_TimTheo_MaYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoTenYTa(string TenYTa)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@TenYTa", TenYTa);
            return db.Execute_Table("PhieuTheoDoi_TimTheo_TenYTa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoNgayGhi(DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuTheoDoi_TimTheoNgayGhi", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoThangGhi(DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuTheoDoi_TimTheoThangGhi", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuTheoDoi_TimTheoNamGhi(DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuTheoDoi_TimTheoNamGhi", para, CommandType.StoredProcedure);
        }
    }
}
